﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
namespace Xiaowei.ViewModel
{
    public class MiniModeViewModel : ViewModelBase
    {
        public event Action Activated;
        public event Action AbortActivated;
        public event Action <string> SpeechRecognizing;
        public event Action SpeechRecognized;
        public event Action ProcessEnded;
        public event Action ConversationEnded;
        public event Action <string> AlarmArrieved;
        public event Action HideChatBubble;
        private static readonly Lazy<MiniModeViewModel> LazyInstance = new Lazy<MiniModeViewModel>(() =>
        {
            return new MiniModeViewModel();
        }, LazyThreadSafetyMode.ExecutionAndPublication);

        public static MiniModeViewModel Instance => LazyInstance.Value;

        private MiniModeViewModel()
        {
            //MiniModeHandler.Activated += ()=> Activated?.Invoke();
            //MiniModeHandler.AbortActivated += () => AbortActivated?.Invoke();
            //MiniModeHandler.SpeechRecognizing += (text) => SpeechRecognizing?.Invoke(text);
            //MiniModeHandler.SpeechRecognized += () => SpeechRecognized?.Invoke();
            //MiniModeHandler.ProcessEnded += () => ProcessEnded?.Invoke();
            //MiniModeHandler.ConversationEnded += () => ConversationEnded?.Invoke();
            //MiniModeHandler.AlarmArrieved += (data) => AlarmArrieved?.Invoke(data);
            //MiniModeHandler.SetMuteState += (isMuted) => { 
            //    if(isMuted)
            //    {
            //        MuteButtonIcon = "/Assets/images/mute-s@3x.png";
            //    }
            //    else
            //    {
            //        MuteButtonIcon = "/Assets/images/mute@3x.png";
            //    }
            //};
            //MiniModeHandler.HideChatBubble += () => HideChatBubble?.Invoke();
        }

        private string speechRecognizingText = "";
        public string SpeechRecognizingText
        {
            get
            {
                return speechRecognizingText;
            }
            set
            {
                if(speechRecognizingText!=value)
                {
                    speechRecognizingText = value;
                    UpdateValue(nameof(SpeechRecognizingText));
                }
            }
        }
        private string muteButtonIcon= "/Assets/images/mute@3x.png";
        public string MuteButtonIcon
        {
            get
            {
                return muteButtonIcon;
            }
            set
            {
                if (muteButtonIcon != value)
                {
                    muteButtonIcon = value;
                    UpdateValue(nameof(MuteButtonIcon));
                }
            }
        }

        public override void Dispose()
        {
            //throw new NotImplementedException();
        }
    }
}
